package edu.misaka.moe.dao;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import edu.misaka.moe.dao.iface.HobbyDao;
import edu.misaka.moe.domain.Hobby;
import edu.misaka.moe.utils.JdbcTemplate;

public class HobbyDaoImpl implements HobbyDao {


	public List<Hobby> getHobbies() {
		String sql="select id,name,code from hobby";
		List<Hobby> list0=new ArrayList<>();
		List<Hobby> list=JdbcTemplate.query(sql, (rs)->{
			try {
				while(rs.next()) {
					Hobby hobby=new Hobby(rs.getInt(1),rs.getString(2),rs.getString(3),false);
					list0.add(hobby);
				}
			} catch (SQLException e) {
				
				e.printStackTrace();
			}
			return list0;
		}, new Object[] {});
		return list;
	}

}
